<?php
/**
 * Created by PhpStorm.
 * User: hepenghui
 * Date: 2018/9/10
 * Time: 上午10:49
 */

namespace common\models;

use backend\models\user\UserBaseInfor;
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;

class Receiver extends ActiveRecord
{

    public static function tableName()
    {
        return '{{%receive_uid_list}}';
    }

    public function rules()
    {
        return [
            [["uid"],"string"],
            [["uid"],"required"]
        ];
    }

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ["ctime"],
                ],
                "value" => new Expression('NOW()')
            ]
        ];
    }

    public function attributeLabels()
    {
        return [
            "uid" => "用户ID"
        ];
    }

    public function getUserinfo()
    {
        return $this->hasOne(UserBaseInfor::className(),["user_guid" => "uid"]);
    }
}